package com.zwh.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zwh.dao.BannerDAO;
import com.zwh.entity.Banner;
import com.zwh.entity.PageDTO;

import javax.annotation.Resource;

@Service("bannerService")
@Transactional
public class BannerServiceImpl implements BannerService {
	@Resource
	private BannerDAO bannerDAO;
	@Override
	@ResponseBody
	@Transactional(readOnly=true,propagation=Propagation.SUPPORTS)
	public PageDTO<Banner> selectBanner(int pageSize,int pageIndex) {
		PageDTO<Banner> pageDTO = new PageDTO<Banner>();
		int start=pageIndex*pageSize-pageSize;
		pageDTO.setRows(bannerDAO.selectBanner(start,pageSize));
		pageDTO.setTotal(bannerDAO.count());
		return pageDTO;
	}

	@Override
	public void updateStatus(Integer id,Integer status) {
		
		bannerDAO.updateStatus(id,status);
		
	}

	@Override
	public void deleteBanner(Integer id) {
		
		bannerDAO.deleteBanner(id);
		
	}
	
	@Override
	public void addBanner(Banner banner) {
		
		bannerDAO.addBanner(banner);
	}

	@Override
	public void deleteBanners(Integer[] ids) {
		bannerDAO.deleteBanners(ids);
		
	}

}
